Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trigger in Zabbix 4.0 LTS, add support to systemd 219 (CentOS 7) #37

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

valerio-bozzolan
Copy link
Contributor

@valerio-bozzolan valerio-bozzolan commented Feb 2, 2023

Changes included in this pull request (batteries included):

  • 65ac4fa - fix the "status" trigger in Zabbix 4.0 LTS
  • f6844c4 - add support to systemd 219 (welcome again CentOS 7)
  • 2263deb - rename 2 files so that are visible from GitHub web (before this change they are truncated)

I've splitted my pull request in multiple very small commits to help maintainer in reviewing.

NOTE: I've NOT modified the template of version 5 or the scripts for version 5. If you want, you can test my scripts also in a recent version and I think it will work, so you can adopt my "old" scripts for both versions. But, to be more friendly, I have not taken this decision for you, so I'm keeping both.

Thank you :)

I've tested this in systemd version 219.

To be honest the script marked as "old" is also compatible with
recent systemd versions, but I'm not bold enough to rewrite that.

Again: this change does NOT change any already-in-use script.
The template of Zabbix version 4.0 LTS checks the
wrong systemd status value. The value is supposed to be:

- 1 if the service is running
- 0 if the service is NOT running

And in fact the template of version 5.0 checks that, since
it checks last()=0. Instead, the template of version 4.0
checks if last()<>0.

This change has NO impact on the template 5.0.
# Don't alert if the server has just been restarted
uptime=$(date +%s -d "$(systemctl show --value -p ActiveEnterTimestamp sysinit.target)")
uptime=$(date +%s -d "$uptime_value")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just extracted the variable

@@ -195,7 +195,7 @@
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{SystemD service monitoring template:systemd.service.status[{#SERVICE}].last()}&lt;&gt;0</expression>
<expression>{SystemD service monitoring template:systemd.service.status[{#SERVICE}].last()}=0</expression>
Copy link
Contributor Author

@valerio-bozzolan valerio-bozzolan Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now Zabbix 4 checks the last()=0. Note that Zabbix 5 also checks that:

I don't know why v4 was last()<>0. Probably the related v4 script had different return values than the current version. By the way now it's correct (1 = running, 0 = stopped).

@valerio-bozzolan
Copy link
Contributor Author

Do you have any question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant